package cc.vv.btpartyjob.jnimodule.fragment

import android.os.Bundle
import android.view.View
import cc.vv.btpartyjob.jnimodule.R
import cc.vv.btpartyjob.jnimodule.adapter.LifeWouldAdapter
import cc.vv.btpartyjob.jnimodule.binder.BaseBinder
import cc.vv.btpartyjob.jnimodule.delegate.LifeWouldFragmentDelegate
import cc.vv.btpartyjob.jnimodule.server.JniDataServer
import cc.vv.mvp.binder.BaseDataBinder
import cc.vv.mvp.fragment.BaseFragmentMVP
import com.chad.library.adapter.base.BaseQuickAdapter

/**
 * 生活会相关的item列表功能的fragment
 * Created by Chen.qi on 2018/10/29.
 */
class LifeWouldFragment : BaseFragmentMVP<LifeWouldFragmentDelegate>() {
    /**
     * 数据适配器
     */
    private var mAdapter: LifeWouldAdapter? = null

    /**
     * item点击事件
     */
    private var onItemClick: BaseQuickAdapter.OnItemClickListener? = null

    /**
     * 头布局
     */
    private var headView: View? = null

    /**
     * 设置头布局
     */
    fun setAdapterHeadView(headView: View?) {
        this.headView = headView
    }

    /**
     * 设置点击事件
     */
    fun setOnItemClick(onItemClick: BaseQuickAdapter.OnItemClickListener) {
        this.onItemClick = onItemClick
    }

    override fun initData() {
    }

    override fun bindEvenListener() {
        mAdapter?.onItemClickListener = onItemClick
    }

    override fun getDelegateClass(): Class<LifeWouldFragmentDelegate> {
        return LifeWouldFragmentDelegate::class.java
    }

    override fun getDataBinder(): BaseDataBinder<*, *> {
        return BaseBinder()
    }

    override fun initView(bundle: Bundle?) {
        super.initView(bundle)
        mAdapter = LifeWouldAdapter(R.layout.item_life_would_list)
        if (null != headView) {
            mAdapter!!.setHeaderView(headView)
        }
        viewDelegate?.setRecyclerViewAdapter(mAdapter)
        viewDelegate?.setAdapterData(mAdapter, JniDataServer.getCommunityData())
    }


}